<template>
	<uni-popup ref="loginModal" type="dialog">
		<uni-popup-dialog type="input" :title="$L('提示')" :content="$L('请登录')" :duration="2000" @confirm="confirmLogin" @close="close" :before-close="true">
		</uni-popup-dialog>
	</uni-popup>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	export default {
		components: {
			uniPopup,
			uniPopupDialog
		},
		
		data(){
			return{
				type:'' //一般为 no_replace 不用 replace跳转
			}
		},

		methods: {
			confirmLogin() {
				this.$refs.loginModal.close()
				this.$emit('confirmLogin')
				if(this.type){
					//no-operation
				}else{
					uni.removeStorageSync('fromurl')
					let url = this.$Route.path;
					const query = this.$Route.query;
					uni.setStorageSync('fromurl', {
						url,
						query
					});
				}
				this.$Router.push('/pages/public/login')
			},
			openLogin(type) {
				this.type = type
				this.$refs.loginModal.open()
			},
			close(fn) {
				fn&&fn()
				this.$emit('closeLogin')
				this.$refs.loginModal.close()
			}
		}
	}
</script>

<style>
</style>